package com.test2;

import java.util.ArrayList;
import java.util.List;

public class Test2 {

    public static void main(String[] args) {
        List<Student1> list = new ArrayList<>();

        Student1 stu1 = new Student1("",1);
        Student1 stu2 = new Student1("",2);
        Student1 stu3 = new Student1("",3);

        list.add(stu1);
        list.add(stu2);
        list.add(stu3);
        int i=0;
        for(Student1 stu:list){
            stu.setName("zhangsan"+(i++));
        }

        for(Student1 stu:list){
            System.out.println(stu.getName()+"--"+stu.getAge());
        }

        list.forEach(System.out::println);
    }
}
